package thread;

import handler.LoRaDataHandle;
import request.MyRequest;
import server.MyServer;
/**
 * 创建新线程，实现数据接受和网络访问异步操作
 * 实现数据服务器，等待客户端连接
 *
public class MyThread extends Thread {
	
}
*/
/**
 * 该部分实现想云端服务器申请数据
 * @author cyc
 * date：2018.6.13
 */
public class MyThread extends Thread{
	
	public String deveui;//设备号
	public int limit;//数据量
	public String type;//请求类型
	public String url="https://loraflow.io/v1/application/data";
	public String param="limit=1&appeui=418fae6acfc3d176&token=1v7tbcb52292fedbb6abc287bedee&order=desc";
	
	public void run() {
		while(true) {
			MyRequest request = new MyRequest();
			LoRaDataHandle handle = new LoRaDataHandle();
			handle.Jsonhandle(request.sendGet(url, param));
			try {
				Thread.sleep(60000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
		}
	}
	public int port = 3333;
	public void run1(){
		System.out.println("开启网络连接线程：");
	MyServer server = new MyServer();
	try {
		server.run(port);
	} catch (InterruptedException e) {
		
		e.printStackTrace();
	}
	}
}
